﻿using System;
using System.ComponentModel;
using System.Collections.Generic;

namespace Stopwatch.Data
{
    public class Clock : INotifyPropertyChanged
    {
        private uint _count;
        private TimeSpan _span;
        private TimeSpan _period;

        public event PropertyChangedEventHandler PropertyChanged;

        public Clock()
        {
        }

        /// <summary>
        /// count the press the button
        /// </summary>
        public uint Count
        {
            get { return _count; }
            set
            {
                if (value != _count)
                {
                    _count = value;
                    raisePropertyChanged("Count");
                }
            }
        }

        public TimeSpan Span
        {
            get { return _span; }
            set
            {
                if (value != _span)
                {
                    _span = value;
                    raisePropertyChanged("Span");
                }
            }
        }

        public TimeSpan Period
        {
            get { return _period; }
            set
            {
                if (value != _period)
                {
                    _period = value;
                    raisePropertyChanged("Period");
                }
            }
        }

        protected void raisePropertyChanged(string name)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(name));
            }
        }

    }
}
